package com.burstly.lib.component.networkcomponent;

import android.content.Context;
import android.view.KeyEvent;
import android.view.MotionEvent;
import com.burstly.lib.component.IBurstlyAdaptorListener;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;

public class ClickAwareWrapper extends FocusAwareLayout
{
  static final LoggerExt LOG = LoggerExt.getInstance();
  static final int WAIT_BETWEEN_CLICKS = 2000;
  private final IBurstlyAdaptorListener mAdaptorListener;
  private boolean mIsInterstitial;
  volatile boolean mIsTouchDisabled;
  private final String mNetworkName;
  final String mViewId;

  public ClickAwareWrapper(Context paramContext, IBurstlyAdaptorListener paramIBurstlyAdaptorListener, String paramString1, String paramString2)
  {
    super(paramContext);
    this.mAdaptorListener = paramIBurstlyAdaptorListener;
    this.mViewId = paramString1;
    this.mNetworkName = paramString2;
  }

  private void enableAfterDelay()
  {
    new Thread(new Runnable()
    {
      public void run()
      {
        Utils.lowerCurrentThreadPriority();
        try
        {
          LoggerExt localLoggerExt = ClickAwareWrapper.LOG;
          String str = ClickAwareWrapper.this.mViewId;
          Object[] arrayOfObject = new Object[1];
          arrayOfObject[0] = Integer.valueOf(2000);
          localLoggerExt.logInfo(str, "Banner is not clickable for {0}ms...", arrayOfObject);
          Thread.sleep(2000L);
          ClickAwareWrapper.LOG.logInfo(ClickAwareWrapper.this.mViewId, "Banner is clickable again", new Object[0]);
          ClickAwareWrapper.this.mIsTouchDisabled = false;
          return;
        }
        catch (InterruptedException localInterruptedException)
        {
          while (true)
            ClickAwareWrapper.LOG.logWarning("Click watch thread", localInterruptedException.getMessage(), new Object[0]);
        }
      }
    }).start();
  }

  private static void logEvent(MotionEvent paramMotionEvent)
  {
    switch (paramMotionEvent.getAction())
    {
    case 2:
    default:
      return;
    case 0:
      LOG.logDebug("EVENT TYPE", "DOWN", new Object[0]);
      return;
    case 1:
      LOG.logDebug("EVENT TYPE", "UP", new Object[0]);
      return;
    case 3:
      LOG.logDebug("EVENT TYPE", "CANCEL", new Object[0]);
      return;
    case 4:
    }
    LOG.logDebug("EVENT TYPE", "OUTSIDE", new Object[0]);
  }

  public boolean dispatchKeyEvent(KeyEvent paramKeyEvent)
  {
    if ((1 == paramKeyEvent.getAction()) && (paramKeyEvent.getKeyCode() == 23) && (!this.mIsTouchDisabled) && (this.mAdaptorListener != null))
    {
      LoggerExt localLoggerExt = LOG;
      String str = this.mViewId;
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = this.mNetworkName;
      localLoggerExt.logDebug(str, "onClick {0}.", arrayOfObject);
      this.mAdaptorListener.adWasClicked(this.mNetworkName, this.mIsInterstitial);
      this.mIsTouchDisabled = true;
      enableAfterDelay();
    }
    return super.dispatchKeyEvent(paramKeyEvent);
  }

  public boolean onInterceptTouchEvent(MotionEvent paramMotionEvent)
  {
    logEvent(paramMotionEvent);
    if ((!this.mIsTouchDisabled) && (paramMotionEvent.getAction() == 1) && (this.mAdaptorListener != null))
    {
      this.mAdaptorListener.adWasClicked(this.mNetworkName, this.mIsInterstitial);
      this.mIsTouchDisabled = true;
      enableAfterDelay();
    }
    return false;
  }

  public void setInterstitial(boolean paramBoolean)
  {
    this.mIsInterstitial = paramBoolean;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.ClickAwareWrapper
 * JD-Core Version:    0.6.2
 */